<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@include file="/header.jsp" %>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>生成器测试表</title>
<script type="text/javascript">
function refGrid(){
	$('#datagridtable').datagrid("clearChecked");
	$('#datagridtable').datagrid("options").url='${base}test/testTable/dataList?'+$("form").serialize();
	$('#datagridtable').datagrid("load");  
}

  $(function(){
	  $("#searchbtn").click(function(){refGrid();});
	  
	  $('#datagridtable').datagrid({    
		    singleSelect:false,
		    collapsible:false,
		    url:'${base}test/testTable/dataList?'+$("form").serialize(),
		    method:'post',
		    pagination:true,
		    toolbar:'#toolbar',
			pageSize:20,
			multiSort:true,
			rownumbers:true,
			border:false,
			animate:true,
			idField:'id',
			autoRowHeight:false,
			fitColumns: true,
		    columns:[[ 
		        {field:'id',checkbox:true},    
		          {field:'testName',title:'名称',width:100,sortable:false},
		          {field:'testCode',title:'编号',width:100,sortable:false},
		          {field:'testDate',title:'测试日期',width:100,sortable:false},
		          {field:'testDatetime',title:'测试长日期',width:100,sortable:false,formatter:formatDateTime},
		          {field:'testStatus',title:'状态',width:100,sortable:false,formatter:function(v,r){return formatSelect(v,r,'DEFAULT');}},
		          {field:'testRemark',title:'描述',width:100,sortable:false},
		          {field:'testNote',title:'备注',width:100,sortable:false},
		    ]]    
		});
	  $("#addBtn").click(function(){
		  myDialog({title:"新增信息",src:"${base}test/testTable/addPage",width:750,height:348,callBack:refGrid});
      });
      $("#editBtn").click(function(){
    	  var selOpts =$('#datagridtable').treegrid("getChecked");
			if(selOpts.length==0||selOpts.length>1)
				myAlert("错误信息","请选择一条记录！","e");
			else
			  myDialog({title:"编辑信息",src:"${base}test/testTable/editPage?id="+selOpts[0].id,width:750,height:348,callBack:refGrid});
      });
	 $("#delBtn").click(function(){
		 var selOpts =$('#datagridtable').datagrid("getChecked");
			if(selOpts.length==0){
				myAlert("错误信息","请选择需要删除的记录！","e");
				return;
				}
			ids=[];
			$.each(selOpts,function(i,v){
				     ids.push(v.id);
				});
			myConfirm("提示信息","确定删除选中的数据吗?",function(r){
                  if(r){
                 	 myAjax({url:"${base}test/testTable/delTestTable",data:{"ids":ids},  
                     	 success:function(data){
                               if(data.error=='0')
                             	      refGrid();
                               else
                             	  myAlert("错误信息",data.msg,"e");   
                     	 }}); 
               }
			});
	   });
	 $("#detailBtn").click(function(){
		 var selOpts =$('#datagridtable').datagrid("getChecked");
			if(selOpts.length==0||selOpts.length>1)
				myAlert("错误信息","请选择一条记录！","e");
			else
			  myDialog({title:"查看信息",src:"${base}test/testTable/detailPage?id="+selOpts[0].id,width:750,height:348,
				  callBack:function(){
				  $('#datagridtable').datagrid("clearChecked");
				  }
			  });
	  });
});
</script>
</head>
<body fit="true">
   <div id="toolbar">
   <div class="toolbar_searchcondition">
   <form class="easyui-form" action="${base}testTable"  method="post">
	  名称：<input class="easyui-textbox" name="params['testName']" type="text"/>&nbsp;
	  编号：<input class="easyui-textbox" name="params['testCode']" type="text"/>&nbsp;
	  测试日期：<input class="easyui-datebox" data-options="formatter:fmtDate,parser:parserDate"name="params['testDate']"/>&nbsp;
	  测试长日期：<input class="easyui-datebox" data-options="formatter:fmtDate,parser:parserDate"name="params['testDatetime']"/>&nbsp;
	  状态：<input class="easyui-combobox"  name="params['testStatus']" type="text" data-options='valueField:"itemValue",textField:"itemName",data:${DEFAULT},editable:false'/>&nbsp;
		   <a href="#" class="easyui-linkbutton searchbtn" iconCls="icon-search" id="searchbtn">查询</a>
		   <!-- <a  class="easyui-linkbutton" style="position:absolute;bottom:-10px;left:45%;" iconCls="icon-section-collapsed" id="conditBtn"></a> --> 
		</form>
	</div>	
		<div class="toolbar_btns">
	        <a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" id="addBtn">添加</a>
			<a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" id="editBtn">编辑</a>
			<a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" id="delBtn">删除</a>
			<a href="#" class="easyui-linkbutton" iconCls="icon-search" plain="true" id="detailBtn">查看</a>
	 </div>
   </div>
	  <table id="datagridtable"  style="width:1200px;height:500px" fit="true"></table>
</body>
</html>